#include <bits/stdc++.h>
using namespace std;

int d[505][505];
int air[505];

int main() {

  int n, m;

  cin >> n >> m;
  int sky = n + 1;

  for (int i = 1; i <= n + 1; i++) {
    for (int j = 1; j <= n + 1; j++) {
      if (i == j)
        continue;
      d[i][j] = 1e18;
    }
  }
  for (int i = 1; i <= m; i++) {
    int u, v, c;
    cin >> u >> v >> c;
    d[u][v] = min(d[u][v], c);
    d[v][u] = min(d[v][u], c);
  }

  // 第n+1点为sky点
  // 有机场的点可以以T的代价到达sky点
  // sky点可以以0的代价到达任意有机场的点
  int k, T;
  cin >> k >> T;
  for (int i = 1; i <= k; i++) {
    int x;
    cin >> x;
    air[x] = 1;
    d[x][sky] = T;
    d[sky][x] = 0;
  }

  // floyd算法
  for (int k = 1; k <= n + 1; k++) {
    for (int i = 1; i <= n + 1; i++) {
      for (int j = 1; j <= n + 1; j++) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  // 处理查询
  // 1. 添加道路，2. 添加机场，3. 查询总费G用

  int q;
  cin >> q;
  while (q--) {
    int opt;
    cin >> opt;
    switch (opt) {
    case 1: {
      int x, y, t;
      cin >> x >> y >> t;
      int tmp = d[x][y];
      d[x][y] = min(d[x][y], t);
      d[y][x] = min(d[y][x], t);
      if (tmp > t) {
        for (int i = 1; i <= n + 1; i++) {
          for (int j = 1; j <= n + 1; j++) {
            d[i][j] =
                min({d[i][j], d[i][x] + t + d[y][j], d[i][y] + t + d[x][j]});
          }
        }
      }

      break;
    }
    case 2: {
      int x;
      cin >> x;
      if (air[x])
        continue;
      air[x] = 1;
      d[x][sky] = T;
      d[sky][x] = 0;
      for (int i = 1; i <= n + 1; i++) {
        for (int j = 1; j <= n + 1; j++) {
          d[i][j] =
              min({d[i][j], d[i][x] + T + d[sky][j], d[i][sky] + 0 + d[x][j]});
        }
      }
      break;
    }
    case 3: {
      int ans = 0;
      for (int i = 1; i <= n; i++) {
        for (int j = i + 1; j <= n; j++) {
          ans += (d[i][j] >= 1e18 ? 0 : d[i][j]);
        }
      }
      cout << ans * 2 << endl;
      break;
    }
    }
  }

  return 0;
}